﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using JobsBoardDAL.DTOs;

namespace JobOffersBrowser.ViewModels
{
    public class OfferViewModel : ViewModelBase
    {
        JobOfferDTO offer;

        public OfferViewModel(JobOfferDTO offer)
        {
            this.offer = offer;
        }

        public int OfferID 
        {
            get
            {
                return this.offer.ID;
            }
        }

        public string Status
        {
            get
            {
                return this.offer.Status.StatusName;
            }
        }

        public DateTime PublishDate
        {
            get
            {
                return this.offer.PublishTime;
            }
        }

        public int ValidDaysRemaining
        {
            get
            {
                return (this.PublishDate.Day + this.offer.ValidityDays) - DateTime.Now.Day;
            }

        }

        public IndustryViewModel Industry
        {
            get
            {
                return new IndustryViewModel(this.offer.Industry);
            }
        }

        public string City
        {
            get
            {
                return this.offer.Location.Town.CityName;
            }
        }

        public string Country
        {
            get
            {
                return this.offer.Location.Country.CountryName;
            }
        }

        public string JobTitle
        {
            get
            {
                return this.offer.JobTitle;
            }
            set
            {
                if (this.offer.JobTitle != value)
                {
                    this.offer.JobTitle = value;
                    OnPropertyChanged("JobTitle");
                }
            }
        }

        public string JobDescription
        {
            get
            {
                return this.offer.JobDescription;
            }
        }

        public CompanyViewModel Company
        {
            get
            {
                return new CompanyViewModel(this.offer.Company);
            }
        }
    }
}